package com.twang.stock.enmu;

import com.alibaba.fastjson.serializer.JSONSerializer;

import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Type;

public enum CommonEnum implements Serializable {
    STOCK("stock_name", ""),
    TO_MAIL("to_mail", "需要接收的邮件"),
    RULE_1_STRONG_RIZE("rule_1_strong_rize", "规则-1：STRONG_RIZE的值"),
    HOT_TAG_STRONG_RIZE("hot_tag_strong_rize", "hot-tag：STRONG_RIZE的值"),
    MINUTES_AVG_VOL("minutes_avg_vol", "分时成交量");

    private String code;
    private String msg;

    CommonEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static CommonEnum getEnum(Integer code) {
        for (CommonEnum status : CommonEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("参数不合法，无法找到对应的枚举类型");
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void write(JSONSerializer jsonSerializer, Object o, Type type, int i) throws IOException {
        jsonSerializer.write(code);
    }
}
